<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function login(){
        $this->display();
    }
    

    public function selectUser(){
        $user['user']=I('post.user');
        $user['password']=I('post.password');
        $login=M('enroll_user');
        $data=$login->where($user)->select();
        // var_dump($data);
        // js.length
        // count($data)获取数组的长度
        if(count($data)>0){
            cookie('enrolluserid',$data[0]['id'],3600);
            cookie('enrollusername',$data[0]['user'],3600);
            redirect(U('Index/index'));
        }else{
            redirect(U('Login/login'));
        }
    }
    public function logOut(){
        // 退出登录
        cookie('enrollusername',null);
        redirect(U('Index/index'));
    }
    public function get_v(){
        $config =    array(
            'fontSize'  =>   30,
            'length'    =>   4,
            'useNoise'  =>   false
        );
        $Verify =     new \Think\Verify($config);
        $Verify->entry(1);
    }
    public function check_v(){
        $verify = new \Think\Verify();
        $res=$verify->check($code,1);
        echo $res;
    }
    public function ajaxCheckVerify(){
        $code=$_POST{'code'};
        $verify=new \Think\Verify();
        $res=$verify->check($code,1);
        if(empty($res)){
            $res= true;
        }else{
            $res= false;
        }
        $this->ajaxReturn($res);
    }
} 
            